home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / tools / install / pinstall / install.pow < prev    next >
Encoding:
Text File  |  1994-06-05  |  16.3 KB  |  319 lines

  1. rem **************************************************************************
  2. rem *                                                                        *
  3. rem *       This is the actual script used to install PowerInstall.          *
  4. rem *                                                                        *
  5. rem * If you're running the PowerInstall install program, then you're        *
  6. rem * viewing this file via a one line script command called 'VIEW_FILE'.    *
  7. rem * You can find it a couple pages down where the main menu is read via    *
  8. rem * 'READ_MENU'.                                                           *
  9. rem *                                                                        *
  10. rem **************************************************************************
  11.  
  12. rem **************************************************************************
  13. rem *                                                                        *
  14. rem *                           Declare variables                            *
  15. rem *                                                                        *
  16. rem **************************************************************************
  17.  
  18. intvar  titlewin                                     Title window handle
  19. intvar  mainmenu                                     Main menu window handle
  20. intvar  destwin                                      Install path window
  21. intvar  errwin                                       Error window handle
  22. intvar  msgwin                                       General messages
  23.  
  24. intvar  key                                          Hold key from read_menu
  25. intvar  tmp                                          Temp for return codes
  26. intvar  menusel                                      Menu sel from read_menu
  27.  
  28. strvar  destdir                                      Dir to install to
  29. strvar  errstr                                       String for error window
  30. strvar  copydest                                     Build file copy paths
  31. strvar  srcfile                                      Source file for copy
  32.  
  33. rem **************************************************************************
  34. rem *                                                                        *
  35. rem *                             Define windows                             *
  36. rem *                                                                        *
  37. rem **************************************************************************
  38.  
  39. mainmenu = define_win 24 9 28 8 1 yes ' ' black white black  white
  40.  
  41. titlewin = define_win  32 3 24 2 1 yes ' ' black white blue white
  42. win_puts   titlewin 1 1 " Welcome to PowerInstall v1.0 "
  43.  
  44. msgwin = define_win 62 5 9 10 2 yes ' ' white blue ltwhite black
  45.  
  46. errwin = define_win 62 5 9 17 2 yes ' ' white red ltwhite black
  47. win_puts   errwin 1 4 "[ Hit <enter> or click left ]"
  48.  
  49. destwin = define_win 54 5 13 7 1 yes ' ' white blue ltbrown blue
  50. win_puts destwin 2  2 "Directory: "
  51. win_puts destwin 0 13 " Where to put PowerInstall ? "
  52.  
  53. rem **************************************************************************
  54. rem *                                                                        *
  55. rem *                          Define menu options                           *
  56. rem *                                                                        *
  57. rem *  Window handle. Window column & row. Hotkey (0 if none).               *
  58. rem *                                                                        *
  59. rem *                                                                        *
  60. rem **************************************************************************
  61.  
  62. define_menusel mainmenu 1 1 0 ltwhite black blue white " Read THIS Script     "
  63. define_menusel mainmenu 1 2 0 ltwhite black blue white " Read READ.ME         "
  64. define_menusel mainmenu 1 3 0 ltwhite black blue white " Read VENDOR.DOC      "
  65. define_menusel mainmenu 1 4 0 ltwhite black blue white " Read WHATSNEW        "
  66. define_menusel mainmenu 1 5 0 ltwhite black blue white " Read ORDER.DOC       "
  67. define_menusel mainmenu 1 6 0 ltwhite black blue white " Install PowerInstall "
  68. define_menusel mainmenu 1 7 0 ltwhite black blue white " Exit                 "
  69.  
  70. rem **************************************************************************
  71. rem *                                                                        *
  72. rem *                             Begin script                               *
  73. rem *                                                                        *
  74. rem **************************************************************************
  75.  
  76. destdir = "C:\PINST"                                        Initial directory
  77.  
  78. curtain
  79. show_win titlewin                                           Show title window
  80. pause
  81. pause
  82.  
  83. win_puts msgwin 14 2 "How'd you like that installation ?"
  84. show_win msgwin
  85. read_key
  86. hide_win msgwin
  87. win_puts msgwin 14 2 "                                  "
  88.  
  89. win_puts msgwin 2 2 "You just witnessed an ordinary self-extracting archive..."
  90. show_win msgwin
  91. read_key
  92. hide_win msgwin
  93. win_puts msgwin 2 2 "                                                         "
  94.  
  95. win_puts msgwin 5 2 "...converted by PowerInstall to be self-installing !"
  96. show_win msgwin
  97. read_key
  98. hide_win msgwin
  99. win_puts msgwin 5 2 "                                                    "
  100.  
  101. win_puts msgwin 4 2 "Also, THIS program is a PowerInstall compiled script."
  102. show_win msgwin
  103. read_key
  104. hide_win msgwin
  105. win_puts msgwin 4 2 "                                                     "
  106.  
  107. win_puts msgwin 12 2 "And now, lets install PowerInstall..."
  108. show_win msgwin
  109. read_key
  110. hide_win msgwin
  111. win_puts msgwin 12 2 "                                     "
  112.  
  113. rem **************************************************************************
  114. rem *                                                                        *
  115. rem *                             Read main menu                             *
  116. rem *                                                                        *
  117. rem **************************************************************************
  118.  
  119. label menuloop                                          Used for GOTO,GOSUB
  120.  
  121. key = read_menu mainmenu menusel                 This performs the whole menu
  122.  
  123. if key == ESC goto done_install                         Exit installation
  124. if key <> 13  goto menuloop                             Wait for enter key
  125.  
  126. if menusel == 0 view_file "install.pow"                 View this script
  127. if menusel == 1 view_file "read.me"                     View read.me
  128. if menusel == 2 view_file "vendor.doc"                  View vendor.doc
  129. if menusel == 3 view_file "whatsnew"                    View whatsnew
  130. if menusel == 4 view_file "order.doc"                   View order.doc
  131. if menusel == 5 gosub     do_install                    Perform installation
  132. if menusel == 6 goto      done_install                  Exit installation
  133.  
  134. goto menuloop                                           Back to menu
  135.  
  136. rem **************************************************************************
  137. rem *                                                                        *
  138. rem *                          Do install                                    *
  139. rem *                                                                        *
  140. rem **************************************************************************
  141.  
  142. label do_install
  143.  
  144. show_win destwin                                                Show window
  145.  
  146. tmp = read_string destwin 13 2 38 ltwhite black yes destdir     Read path
  147. if tmp <> 0 goto verify_it                                      Aborted ?
  148.  
  149. hide_win destwin                                                Hide window
  150. return                                                          Back to menu
  151.  
  152. label verify_it
  153.  
  154. tmp = verify_path destdir                                       Verify path
  155.  
  156. rem ********************** Critical error *********************************
  157.  
  158. if tmp <> 4 goto not_crit                               Critical ?
  159. errstr = "                       Drive not ready"
  160. gosub show_error                                        Show error
  161. goto  do_install                                        Get path again
  162.  
  163. rem ********************** Is path a file ? *******************************
  164.  
  165. label not_crit
  166. if tmp <> 3 goto notfile                                Is a file ?
  167. errstr = "                        That is a file"
  168. gosub show_error                                        Show error
  169. goto  do_install                                        Get path again
  170.  
  171. rem *************************** Bad dir ***********************************
  172.  
  173. label notfile
  174. if tmp <> 2 goto not_disk                               Bad dir ?
  175.  
  176. win_puts msgwin 13 2 "Directory not found. Create (y/N) ?"
  177. show_win msgwin                                         Prompt to create
  178. tmp = read_key                                          Get answer
  179. hide_win msgwin
  180. win_puts msgwin 13 2 "                                   "
  181. if tmp <> 'Y' if tmp <> 'y' goto do_install             'Y' key pressed ?
  182.  
  183. mkdir destdir                                           Create directory
  184.  
  185. goto  good_dir                                          Get path again
  186.  
  187. rem *************************** Bad disk **********************************
  188.  
  189. label not_disk
  190. if tmp <> 1 goto good_dir                                Bad disk ?
  191. errstr = "                           Bad disk"
  192. gosub show_error                                         Show error
  193. goto  do_install                                        Get path again
  194.  
  195.  
  196. rem **************************************************************************
  197. rem *                                                                        *
  198. rem *               Good install directory. Copy files.                      *
  199. rem *                                                                        *
  200. rem **************************************************************************
  201.  
  202. label good_dir                                           End of installation
  203.  
  204. hide_win destwin                                         Remove path window
  205.  
  206. win_puts msgwin 16 2 "Copying PowerInstall files..."     Write line
  207. show_win msgwin                                          Show message
  208.  
  209. srcfile = "install.pow"                                       File to copy
  210. gosub copy_srcfile                                            Do the copy
  211. if tmp == 1 goto donedoinstall                                Abort on error
  212. srcfile = "menu.pow"                                          File to copy
  213. gosub copy_srcfile                                            Do the copy
  214. if tmp == 1 goto donedoinstall                                Abort on error
  215. srcfile = "stack.pow"                                         File to copy
  216. gosub copy_srcfile                                            Do the copy
  217. if tmp == 1 goto donedoinstall                                Abort on error
  218. srcfile = "str_dir.pow"                                       File to copy
  219. gosub copy_srcfile                                            Do the copy
  220. if tmp == 1 goto donedoinstall                                Abort on error
  221. srcfile = "window.pow"                                        File to copy
  222. gosub copy_srcfile                                            Do the copy
  223. if tmp == 1 goto donedoinstall                                Abort on error
  224. srcfile = "pinst.exe"                                         File to copy
  225. gosub copy_srcfile                                            Do the copy
  226. if tmp == 1 goto donedoinstall                                Abort on error
  227. srcfile = "whatsnew"                                          File to copy
  228. gosub copy_srcfile                                            Do the copy
  229. if tmp == 1 goto donedoinstall                                Abort on error
  230. srcfile = "ascii.doc"                                         File to copy
  231. gosub copy_srcfile                                            Do the copy
  232. if tmp == 1 goto donedoinstall                                Abort on error
  233. srcfile = "pinst.doc"                                         File to copy
  234. gosub copy_srcfile                                            Do the copy
  235. if tmp == 1 goto donedoinstall                                Abort on error
  236. srcfile = "order.doc"                                         File to copy
  237. gosub copy_srcfile                                            Do the copy
  238. if tmp == 1 goto donedoinstall                                Abort on error
  239. srcfile = "quick.doc"                                         File to copy
  240. gosub copy_srcfile                                            Do the copy
  241. if tmp == 1 goto donedoinstall                                Abort on error
  242. srcfile = "vendor.doc"                                        File to copy
  243. gosub copy_srcfile                                            Do the copy
  244. if tmp == 1 goto donedoinstall                                Abort on error
  245. srcfile = "read.me"                                           File to copy
  246. gosub copy_srcfile                                            Do the copy
  247.  
  248. label donedoinstall
  249.  
  250. hide_win msgwin                                          Remove message.
  251. win_puts msgwin 16 2 "                             "     Clear line
  252. return
  253.  
  254. rem **************************************************************************
  255. rem *                                                                        *
  256. rem *                         Copy file routine.                             *
  257. rem *                                                                        *
  258. rem * destdir = Destination path.                                            *
  259. rem * srcfile = Source filename.                                             *
  260. rem *                                                                        *
  261. rem **************************************************************************
  262.  
  263. label copy_srcfile
  264.  
  265. copydest = addpathfile destdir srcfile                   Build dest path
  266. tmp = copy_file srcfile copydest                         Copy file
  267. if tmp == 0 return
  268.  
  269. gosub bad_copy                                           Copy error
  270. tmp = 1                                                  Signal error
  271. return                                                   Back to installer
  272.  
  273. rem **************************************************************************
  274. rem *                                                                        *
  275. rem *               File copy error. tmp = COPY_FILE error code.             *
  276. rem *                                                                        *
  277. rem **************************************************************************
  278.  
  279. label bad_copy
  280.  
  281. if tmp == 1 errstr = "                       Out of memory"
  282. if tmp == 2 errstr = "                   Can't open source file"
  283. if tmp == 3 errstr = "                 Can't open destination file"
  284. if tmp == 4 errstr = "                         Disk full"
  285.  
  286. gosub show_error                                          Show error message
  287. return                                                    Return to mani menu
  288.  
  289. rem **************************************************************************
  290. rem *                                                                        *
  291. rem *                           Show error window                            *
  292. rem *                                                                        *
  293. rem **************************************************************************
  294.  
  295. label show_error
  296.  
  297. win_puts errwin 1 2 "                                                    "
  298. win_puts errwin 1 2 errstr                          Clear line and show string
  299.  
  300. show_win errwin
  301. leftmouse                                           Enter or left click
  302. hide_win errwin
  303.  
  304. return
  305.  
  306. rem **************************************************************************
  307. rem *                                                                        *
  308. rem *                              Exit install                              *
  309. rem *                                                                        *
  310. rem **************************************************************************
  311.  
  312. label done_install
  313.  
  314. hide_win mainmenu
  315. hide_win titlewin                                        Remove windows
  316. clrscr
  317. cursorxy 0 0
  318. exit 0                                                   Exit
  319.